package com.uzai.console.web.md;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.md.mdconfigplan.*;
import com.uzai.console.dto.pdd.pddtoken.PddTokenIdDto;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.md.mdconfigplan.MdConfigPlanService;
import com.uzai.console.vo.md.mdconfigplan.MdConfigPlanVo;
import com.uzai.console.vo.pdd.pddtoken.PddTokenRecordVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liuqi
 * @date 2021年08月25日 20:15
 */
@Api(value = "免单配置方案",tags = "免单管理|免单配置方案")
@ApiSort(60)
@RestController
public class MdConfigPlanContoller extends BaseController {
    private Logger logger = LoggerFactory.getLogger(MdConfigPlanContoller.class);

    @Autowired
    private MdConfigPlanService mdConfigPlanService;

    @ApiOperation(value = "查询所有免单配置方案列表", notes = "查询所有免单配置方案列表", response = MdConfigPlanVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/mdConfigPlan/findMdConfigPlanList")
    public Object findMdConfigPlanList(@RequestBody MdConfigPlanQuery mdConfigPlanQuery){
        return mdConfigPlanService.findMdConfigPlanList(mdConfigPlanQuery);
    }

    @ApiOperation(value = "查询所有免单配置方案详情", notes = "查询所有免单配置方案详情", response = MdConfigPlanVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/mdConfigPlan/findMdConfigPlan")
    public Object findMdConfigPlan(@RequestBody MdConfigPlanIdDto mdConfigPlanIdDto){
        return mdConfigPlanService.findMdConfigPlan(mdConfigPlanIdDto);
    }

    @ApiOperation(value = "添加免单配置方案", notes = "添加免单配置方案", response = MdConfigPlanVo.class)
    @ApiOperationSupport(order = 3)
    @PostMapping("/mdConfigPlan/addMdConfigPlan")
    public Object addMdConfigPlan(@RequestBody MdConfigPlanDto mdConfigPlanDto){
        return mdConfigPlanService.addMdConfigPlan(mdConfigPlanDto);
    }

    @ApiOperation(value = "修改免单配置方案", notes = "添加免单配置方案", response = Boolean.class)
    @ApiOperationSupport(order = 4)
    @PostMapping("/mdConfigPlan/updateMdConfigPlan")
    public Object updateMdConfigPlan(@RequestBody MdConfigPlanDto mdConfigPlanDto){
        mdConfigPlanService.updateMdConfigPlan(mdConfigPlanDto);
        return true;
    }

    @ApiOperation(value = "删除免单配置方案", notes = "删除免单配置方案", response = Boolean.class)
    @ApiOperationSupport(order = 5)
    @PostMapping("/mdConfigPlan/deleteMdConfigPlan")
    public Object deleteMdConfigPlan(@RequestBody MdConfigPlanIdDto mdConfigPlanIdDto){
        mdConfigPlanService.deleteMdConfigPlan(mdConfigPlanIdDto);
        return true;
    }

    @ApiOperation(value = "复制免单配置方案", notes = "复制免单配置方案", response = MdConfigPlanVo.class)
    @ApiOperationSupport(order = 8)
    @PostMapping("/mdConfigPlan/copyMdConfigPlan")
    public Object copyMdConfigPlan(@RequestBody MdConfigPlanCopyDto mdConfigPlanCopyDto){
        return mdConfigPlanService.copyMdConfigPlan(mdConfigPlanCopyDto);
    }

    @ApiOperation(value = "修改免单配置方案名称", notes = "修改免单配置方案名称", response = Boolean.class)
    @ApiOperationSupport(order = 9)
    @PostMapping("/mdConfigPlan/updateMdConfigPlanName")
    public Object updateMdConfigPlanName(@RequestBody MdConfigPlanUpdateNameDto mdConfigPlanUpdateNameDto){
        return mdConfigPlanService.updateMdConfigPlanName(mdConfigPlanUpdateNameDto);
    }

    @SystemLogType(model = SystemModelEnum.PddToken, type = OperationTypeEnum.RECORD)
    @ApiOperation(value = "免单配置拼多多联盟备案", notes = "免单配置拼多多联盟备案", response = PddTokenRecordVo.class)
    @ApiOperationSupport(order = 10)
    @PostMapping("/mdConfigPlan/recordPddToken")
    public Object recordPddToken(@RequestBody PddTokenIdDto pddTokenIdDto){
        return mdConfigPlanService.recordPddToken(pddTokenIdDto);
    }

}
